/**
 * @Project Name:blog-login-api
 * @Package Name:cn.hoofungson.blog.login.api.client.oauth2
 * @Since JDK 1.8
 */

package cn.hoofungson.blog.login.api.client.oauth2;

import cn.hutool.json.JSONObject;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @Description: OAuth2FeignClient
 * @Author 胡松 hoofungson@163.com
 * @Date 2020-03-26 13:37
 * @Version V1.0
 */
@FeignClient("blog-authentication-server")
public interface OAuth2FeignClient {

    /**
     * 认证
     *
     * @param grantType
     * @param scope
     * @param username
     * @param password
     * @return
     **/
    @PostMapping(value = "/oauth/token", headers = {"Authorization=Basic Vmg5U0xidjA6RkxxUFFedzM1NlM2YUdlVA=="})
    ResponseEntity<JSONObject> auth(
            @RequestParam("grant_type") String grantType
            , @RequestParam("scope") String scope
            , @RequestParam("username") String username
            , @RequestParam("password") String password);

    /**
     * 检查Token
     *
     * @param token
     * @return
     **/
    @PostMapping("/oauth/check_token")
    ResponseEntity<JSONObject> checkToken(@RequestParam("token") String token);
}
